<?php
/*
License:
	MIT-style license

Author:
	Jan Kassens
*/
class MooResponse{

	private $data;

	public static function arguments($args){
		return new MooResponse(array('args' => $args));
	}

	public static function error($error){
		return new MooResponse(array('error' => $error));
	}

	public static function script($script){
		return new MooResponse(array('script' => $script));
	}

	public function __construct($data = array()){
		$this->data = $data;
	}

	public function __set($prop, $val){
		switch($prop){
			case 'arguments':
				$this->data['args'] = $val;
				break;
			case 'error':
				$this->data['error'] = $val;
				break;
			case 'script':
				$this->data['script'] = $val;
				break;
			default:
				throw new Exception("Setting unknown property $prop.");
		}
	}

	public function __toString(){
		return json_encode($this->data);
	}

}
?>